package com.xiaren.biz;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;

import javax.swing.JOptionPane;

import com.xiaren.common.ObjectConstant;
import com.xiaren.ui.edit.FileEdit;

/**
 * 按钮监听事件
 *
 * @author xiaren
 * @主页 http://www.leaf123.cn/
 * @邮箱 xia5523@qq.com
 */
public class ListenerEvent {
	// 用于文件保存按钮的监听
	public static ActionListener btnSave() {

		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				FileEdit fileEdit = ((FileEdit) ObjectConstant.mainEdit.getSelectedComponent());
				if (fileEdit == null){
					return ;
				}
				fileEdit.saveMySelf();
			}
		};
	}

	// 保存所有
	public static ActionListener btnSaveAll() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				PublicFunction.saveAllFile();
			}

		};
	}

	// 退出事件
	public static ActionListener btnExit() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				PublicFunction.exitSys();
			}

		};
	}

	/**
	 * 帮助
	 *
	 * @return
	 */
	public static ActionListener btnHelp() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				PublicFunction.help();
			}

		};
	}

	/**
	 * 是否可见
	 *
	 * @return
	 */
	public static ActionListener btnVisible() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (ObjectConstant.mainFrame.isVisible()) {
					ObjectConstant.mainFrame.setVisible(false);
				}
			}

		};
	}

	/**
	 * 图标是否在
	 *
	 * @return
	 */
	public static ActionListener btnIcon() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				if (ObjectConstant.titleWindow.isVisible()) {
					ObjectConstant.titleWindow.setVisible(false);
				} else {
					ObjectConstant.titleWindow.setVisible(true);
					ObjectConstant.titleWindow.setAlwaysOnTop(true);
				}
			}
		};
	}

	/**
	 * 截屏功能
	 *
	 * @return
	 */
	public static ActionListener btnPrint() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {

			}
		};
	}

	public static ActionListener btnRumCmd() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showInputDialog(null, "输入cmd命令", "该功能暂时未启用!");
			}
		};
	}

	public static ActionListener menuItemPrint() {
		return new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				System.out.println(e);
			}
		};
	}

	public static void main(String[] args) throws IOException,
			InterruptedException {
	}

}
